/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 *//*

package cz.worsik.android.test.rideshare.util.listener;

import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import cz.worsik.android.test.rideshare.R;
import cz.worsik.android.test.rideshare.MainActivity;
import cz.worsik.android.test.rideshare.constants.ViewConst;

	public class EnableNamechangeListener implements View.OnClickListener 
	{
		// musi se pricist k startovnimu ID
		public int position;
		MainActivity a;
		
		public EnableNamechangeListener(MainActivity a, int position)
		{
			this.position = position;
			this.a = a;
		}
		
		public void onClick(View v) 
		{
			EditText name = (EditText) a.findViewById(ViewConst.SETTINGS_NAME_START_ID+position);
			CheckBox cb = (CheckBox) a.findViewById(ViewConst.SETTINGS_DRIVER_CHECK_START_ID+position);
			Button btn = (Button) a.findViewById(ViewConst.SETTINGS_EDIT_BTN_START_ID+position);
			EditText price = (EditText) a.findViewById(ViewConst.SETTINGS_PRICE_START_ID+position);
			
			if (name.isEnabled())
			{
				// provedeme ulozeni a prepnuti na disabled
				a.getDb().open();
				Boolean done = a.getDb().updateContactName(position,name.getText().toString(),cb.isChecked(),Integer.parseInt(price.getText().toString()));
				a.getDb().close();
				
				if (done)
				{
					// zmena zobrazeni
					name.setEnabled(false);
					name.clearFocus();
					cb.setEnabled(false);
					btn.setText(a.getString(R.string.edit));
					price.setEnabled(false);

					a.showToast(a.getString(R.string.msg_changes_applied), false);
				}
				else
				{
					a.showToast(a.getString(R.string.msg_changes_not_applied), false);
				}
			}
			else
			{
				// provedeme prepnuti na enabled
				name.setEnabled(true);
				cb.setEnabled(true);
				btn.setText(a.getString(R.string.save));
				price.setEnabled(true);
				// pokud neni zadana cena, napis tam 25
				if ("".equals(price.getText().toString())) {
					price.setText("25");
				}
			}
		}
	}
*/
